import {ref, computed} from 'vue'
import {defineStore} from 'pinia'

export const useAppStore = defineStore('app', {
    //状态  state:()=>{return{count:0}}
    state: () => ({count: 0,}),
    //计算属性，获取状态数据，可以包装，要求有返回值
    getters: {
        getCount(): number {
            return this.count * 2
        }
    },
    //改变状态数据
    actions: {
        change(n: number): void {
            this.count += n
        }
    },
    //persist: true //
    persist: {
        key: 'userapp',
        storage: sessionStorage,
    }
})
